package xxl

import (
	"github.com/xxl-job/xxl-job-executor-go"
	"net/http"
)

// JobRunHandler XxlJobRunHandler
func JobRunHandler(exec xxl.Executor) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		exec.RunTask(w, r)
	}
}

// KillHandler XxlJobRunHandler
func KillHandler(exec xxl.Executor) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		exec.KillTask(w, r)
	}
}

// JobLogHandler XxlJobRunHandler
func JobLogHandler(exec xxl.Executor) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		exec.TaskLog(w, r)
	}
}

// JobBeatHandler XxlJobBeatHandler
func JobBeatHandler(exec xxl.Executor) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		exec.Beat(w, r)
	}
}

// JobIdleBeatHandler JobIdleBeatHandler
func JobIdleBeatHandler(exec xxl.Executor) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		exec.IdleBeat(w, r)
	}
}
